//
//  LTDataBase.m
//  聆听FM
//
//  Created by dllo on 16/6/18.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "LTDataBase.h"

@implementation LTDataBase
+ (LTDataBase *)shareLTDataBaseTool
{
    static LTDataBase *dataBase = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        dataBase = [[LTDataBase alloc] init];
        [dataBase openDB];
        [dataBase creatAlbumTable];
        [dataBase creatRadioTable];
        [dataBase creatVoiceTable];
        [dataBase creatAnchorTable];
        [dataBase creatSoundTable];
        
    });
    return dataBase;
}
//-------------打开数据库-----------------//
- (void)openDB
{
    NSArray *sandBox = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *sandBoxPath = sandBox[0];
    
    NSString *documentPath = [sandBoxPath stringByAppendingPathComponent:@"LTFM.sqlite"];
    NSLog(@"%@",documentPath);
    int result = sqlite3_open([documentPath UTF8String], &dbPoint);
    if (result == SQLITE_OK) {
        NSLog(@"数据库打开成功");
    }else{
        NSLog(@"数据库打开失败");
    }
}
// -------------创建一个专辑表格------------- //
- (void)creatAlbumTable
{
    NSString *sqliteStr = @"create table if not exists album (number integer primary key autoincrement, albumId integer, title text, intro text, playsCounts integer, albumCoverUrl290 text, tracks integer)";
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    if (result == SQLITE_OK) {
        NSLog(@"收藏表格创建成功");
    }else{
        NSLog(@"收藏表格创建失败");
    }
}

// -------------创建一个听单表格------------- //
- (void)creatVoiceTable
{

    
    NSString *sqliteStr = @"create table if not exists voice (number integer primary key autoincrement,specialId integer, coverPathBig text, contentType integer, title text, intro text)";
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    if (result == SQLITE_OK) {
        NSLog(@"收藏听单创建成功");
    }else{
        NSLog(@"收藏听单创建失败");
    }
}

// -------------创建一个广播表格------------- //
- (void)creatRadioTable
{
    
    NSString *sqliteStr = @"create table if not exists radio (number integer primary key autoincrement,radioId integer, rname text, programName text, radioCoverLarge text, radioPlayCount integer, playUrl text)";
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    if (result == SQLITE_OK) {
        NSLog(@"广播表格创建成功");
    }else{
        NSLog(@"广播表格创建失败");
    }
}

// -------------创建一个主播表格------------- //
- (void)creatAnchorTable
{

    NSString *sqliteStr = @"create table if not exists anchor (number integer primary key autoincrement,uid integer, title text, nickname text, smallLogo text)";
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    if (result == SQLITE_OK) {
        NSLog(@"主播表格创建成功");
    }else{
        NSLog(@"主播表格创建失败");
    }
}
// -------------创建一个歌曲表格------------- //
- (void)creatSoundTable
{

    NSString *sqliteStr = @"create table if not exists sound (number integer primary key autoincrement,albumId integer, coverMiddle text, nickname text, title text, comments integer, duration integer, playtimes integer, createdAt integer, musicIndex integer, trackId integer, maxPage integer)";
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    if (result == SQLITE_OK) {
        NSLog(@"声音表格创建成功");
    }else{
        NSLog(@"声音表格创建失败");
    }
}

- (LTIsSaveDataInTable)isSaveDataInTableWithModel_id:(NSInteger)Model_id type:(LTDataType)type
{
    switch (type) {
        case LTAlbum:
        {
            NSString *sqliteStr = [NSString stringWithFormat:@"select * from album where albumId = '%ld'",Model_id];
            
            // 跟随指针
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqliteStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询专辑表格成功");
                
                if (sqlite3_step(stmt) == SQLITE_ROW) {
                    sqlite3_finalize(stmt);
                    NSLog(@"专辑已在表中");
                    return LTInTabel;
                }
                sqlite3_finalize(stmt);
                NSLog(@"专辑没有在表中");
                return LTNotInTable;
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询专辑表格失败啊!");
                return LTSelectError;
            }

        }
            break;
        case LTVoice:
        {
            NSString *sqliteStr = [NSString stringWithFormat:@"select * from voice where specialId = '%ld'",Model_id];
            
            // 跟随指针
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqliteStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询听单表格成功");
                
                if (sqlite3_step(stmt) == SQLITE_ROW) {
                    sqlite3_finalize(stmt);
                    NSLog(@"听单已在表中");
                    return LTInTabel;
                }
                sqlite3_finalize(stmt);
                NSLog(@"听单没有在表中");
                return LTNotInTable;
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询听单表格失败啊!");
                return LTSelectError;
            }
            
        }
            break;
        case LTRadio:
        {

            NSString *sqliteStr = [NSString stringWithFormat:@"select * from radio where radioId = '%ld'",Model_id];
            
            // 跟随指针
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqliteStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询广播表格成功");
                
                if (sqlite3_step(stmt) == SQLITE_ROW) {
                    sqlite3_finalize(stmt);
                    NSLog(@"广播已在表中");
                    return LTInTabel;
                }
                sqlite3_finalize(stmt);
                NSLog(@"广播没有在表中");
                return LTNotInTable;
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询广播表格失败啊!");
                return LTSelectError;
            }

            
        }
            break;

        case LTAnchor:
        {
           
            NSString *sqliteStr = [NSString stringWithFormat:@"select * from anchor where uid = '%ld'",Model_id];
            
            // 跟随指针
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqliteStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询主播表格成功");
                
                if (sqlite3_step(stmt) == SQLITE_ROW) {
                    sqlite3_finalize(stmt);
                    NSLog(@"主播已在表中");
                    return LTInTabel;
                }
                sqlite3_finalize(stmt);
                NSLog(@"主播没有在表中");
                return LTNotInTable;
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询主播表格失败啊!");
                return LTSelectError;
            }
            
        }
            break;
        case LTSound:
        {

            NSString *sqliteStr = [NSString stringWithFormat:@"select * from sound where trackId = '%ld'",Model_id];
            
            // 跟随指针
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqliteStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询声音表格成功");
                
                if (sqlite3_step(stmt) == SQLITE_ROW) {
                    sqlite3_finalize(stmt);
                    NSLog(@"声音已在表中");
                    return LTInTabel;
                }
                sqlite3_finalize(stmt);
                NSLog(@"声音没有在表中");
                return LTNotInTable;
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询声音表格失败啊!");
                return LTSelectError;
            }

        }
            break;
    }
}

//添加albumModel

- (void)insertDataWithAlbumModel:(LTAlbumModel *)model
{
    
    NSString *sqliteStr =[NSString stringWithFormat:@"insert into album (albumId, title, intro, playsCounts, albumCoverUrl290, tracks) values('%ld','%@', '%@','%ld','%@','%ld')",model.albumId, model.title, model.intro, model.playsCounts, model.albumCoverUrl290,model.tracks];
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    
    if (result == SQLITE_OK) {
        NSLog(@"添加专辑成功");
    }else{
        NSLog(@"添加专辑失败");
    }
}

//添加听单model
- (void)insertDataWithVoiceModel:(ZCSListenListDetailModel *)model
{
    
    NSString *sqliteStr =[NSString stringWithFormat:@"insert into voice (specialId, coverPathBig, contentType, title, intro) values('%ld','%@', '%ld','%@','%@')",model.specialId, model.coverPathBig, model.contentType, model.title, model.intro];
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    
    if (result == SQLITE_OK) {
        NSLog(@"添加听单成功");
    }else{
        NSLog(@"添加听单失败");
    }
}

//添加声音model
- (void)insertDataWithSoundModel:(LTVoiceModel *)model
{
    
    NSString *sqliteStr =[NSString stringWithFormat:@"insert into sound (albumId, coverMiddle, nickname, title, comments, duration, playtimes, createdAt, musicIndex, trackId, maxPage) values('%ld','%@', '%@','%@','%ld', '%ld', '%ld', '%ld', '%ld', '%ld', '%ld')",model.albumId, model.coverMiddle, model.nickname, model.title, model.comments, model.duration, model.playtimes, model.createdAt, model.musicIndex, model.trackId, model.maxPage];
    
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    
    if (result == SQLITE_OK) {
        NSLog(@"添加声音成功");
    }else{
        NSLog(@"添加声音失败");
    }
}

//添加广播model
- (void)insertDataWithRadioModel:(LJLRadioPageModel *)model
{
    
    NSString *sqliteStr =[NSString stringWithFormat:@"insert into radio (radioId, rname, programName, radioCoverLarge, radioPlayCount, playUrl) values('%ld','%@', '%@','%@','%ld', '%@')",model.radioId, model.rname, model.programName, model.radioCoverLarge, model.radioPlayCount, model.playUrl];
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    
    if (result == SQLITE_OK) {
        NSLog(@"添加广播成功");
    }else{
        NSLog(@"添加广播失败");
    }

}
- (void)insertDataWithAnchorModel:(LTAnchorModel *)model
{
    
    NSString *sqliteStr =[NSString stringWithFormat:@"insert into anchor (uid, title, nickname, smallLogo) values('%ld','%@', '%@','%@')",model.uid, model.title, model.nickname, model.smallLogo];
    int result = sqlite3_exec(dbPoint, [sqliteStr UTF8String], nil, nil, nil);
    
    if (result == SQLITE_OK) {
        NSLog(@"添加主播成功");
    }else{
        NSLog(@"添加主播失败");
    }
}


//--------------------删除----------------------//

- (void)delegateDataWithModel_id:(NSInteger)Model_id type:(LTDataType)type
{
    switch (type) {
        case LTAlbum:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from album where albumId = '%ld'",Model_id];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除专辑成功!");
            }else{
                NSLog(@"删除专辑失败!");
            }
        }
            break;
        case LTVoice:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from voice where specialId = '%ld'",Model_id];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除听单成功!");
            }else{
                NSLog(@"删除听单失败!");
            }
        }
            break;
        case LTRadio:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from radio where radioId = '%ld'",Model_id];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除广播成功!");
            }else{
                NSLog(@"删除广播失败!");
            }
        }
            break;
        case LTAnchor:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from anchor where uid = '%ld'",Model_id];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除主播成功!");
            }else{
                NSLog(@"删除主播失败!");
            }
        }
            break;
        case LTSound:
        {
            
            NSString *sqlStr = [NSString stringWithFormat:@"delete from sound where trackId = '%ld'",Model_id];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除声音成功!");
            }else{
                NSLog(@"删除声音失败!");
            }

        }
            break;
       
    }
}

//----------------遍历所有取出---------------//

- (NSMutableArray *)selectAllWithtype:(LTDataType)type
{
    switch (type) {
        case LTAlbum:
        {
            NSString *sqlStr = @"select * from album";
            
            NSMutableArray *courseArr = [NSMutableArray array];
            
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqlStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询所有专辑表格成功!");

                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    NSInteger albumId = sqlite3_column_int64(stmt, 1);
                    const unsigned char *title = sqlite3_column_text(stmt, 2);
                    const unsigned char *intro = sqlite3_column_text(stmt, 3);
                    NSInteger playsCounts = sqlite3_column_int64(stmt, 4);
                    const unsigned char *albumCoverUrl290 = sqlite3_column_text(stmt, 5);
                    NSInteger tracks = sqlite3_column_int64(stmt, 6);
                    
                    NSString *model_title = [NSString stringWithUTF8String:(const char *)title];
                    NSString *model_intro = [NSString stringWithUTF8String:(const char *)intro];
                    NSString *model_albumCover = [NSString stringWithUTF8String:(const char *)albumCoverUrl290];
                    
                    LTAlbumModel *model = [[LTAlbumModel alloc] init];
                    model.albumId = albumId;
                    model.title = model_title;
                    model.intro = model_intro;
                    model.playsCounts = playsCounts;
                    model.albumCoverUrl290 = model_albumCover;
                    model.tracks = tracks;
                    [courseArr addObject:model];
                }
                //
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询教程失败");
            }
            sqlite3_finalize(stmt);
            return courseArr;
        }
            break;
        case LTVoice:
        {
            
            NSString *sqlStr = @"select * from voice";
            
            NSMutableArray *courseArr = [NSMutableArray array];
            
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqlStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询所有听单表格成功!");
                //create table if not exists voice (number integer primary key autoincrement,specialId integer, coverPathBig text, contentType integer, title text, intro text)
                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    NSInteger specialId = sqlite3_column_int64(stmt, 1);
                    const unsigned char *coverPathBig = sqlite3_column_text(stmt, 2);
                    NSInteger contentType = sqlite3_column_int64(stmt, 3);
                    const unsigned char *title = sqlite3_column_text(stmt, 4);
                    const unsigned char *intro = sqlite3_column_text(stmt, 5);
                    
                    NSString *model_coverPathBig = [NSString stringWithUTF8String:(const char *)coverPathBig];
                    NSString *model_title = [NSString stringWithUTF8String:(const char *)title];
                    NSString *model_intro = [NSString stringWithUTF8String:(const char *)intro];
                    ZCSListenListDetailModel *model = [[ZCSListenListDetailModel alloc] init];
                    model.specialId = specialId;
                    model.coverPathBig = model_coverPathBig;
                    model.contentType = contentType;
                    model.title = model_title;
                    model.intro = model_intro;
                    [courseArr addObject:model];
                }
                //
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询听单表失败");
            }
            sqlite3_finalize(stmt);
            return courseArr;
            
        }
            break;
        case LTRadio:
        {
            NSString *sqlStr = @"select * from radio";
            
            NSMutableArray *courseArr = [NSMutableArray array];
            
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqlStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询所有广播表格成功!");
                //  @"create table if not exists radio (number integer primary key autoincrement,radioId integer, rname text, programName text, radioCoverLarge text, radioPlayCount integer, playUrl text)"
                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    NSInteger radioId = sqlite3_column_int64(stmt, 1);
                    const unsigned char *rname = sqlite3_column_text(stmt, 2);
                    const unsigned char *programName = sqlite3_column_text(stmt, 3);
                    const unsigned char *radioCoverLarge = sqlite3_column_text(stmt, 4);
                    NSInteger radioPlayCount = sqlite3_column_int64(stmt, 5);
                    const unsigned char *playUrl = sqlite3_column_text(stmt, 6);
                    
                    NSString *model_radioCoverLarge = [NSString stringWithUTF8String:(const char *)radioCoverLarge];
                    NSString *model_rname = [NSString stringWithUTF8String:(const char *)rname];
                    NSString *model_programName = [NSString stringWithUTF8String:(const char *)programName];
                    NSString *model_playUrl = [NSString stringWithUTF8String:(const char *)playUrl];
                    LJLRadioPageModel *model = [[LJLRadioPageModel alloc] init];
                    model.radioId = radioId;
                    model.rname = model_rname;
                    model.programName = model_programName;
                    model.radioCoverLarge = model_radioCoverLarge;
                    model.radioPlayCount = radioPlayCount;
                    model.playUrl = model_playUrl;
                    [courseArr addObject:model];
                }
                //
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询广播表失败");
            }
            sqlite3_finalize(stmt);
            return courseArr;
        }
            break;
        case LTAnchor:
        {
        
            NSString *sqlStr = @"select * from anchor";
            
            NSMutableArray *courseArr = [NSMutableArray array];
            
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqlStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询所有主播表格成功!");
                
                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    NSInteger uid = sqlite3_column_int64(stmt, 1);
                    const unsigned char *title = sqlite3_column_text(stmt, 2);
                    const unsigned char *nickname = sqlite3_column_text(stmt, 3);
                    const unsigned char *smallLogo = sqlite3_column_text(stmt, 4);
                    NSString *model_title = [NSString stringWithUTF8String:(const char *)title];
                    NSString *model_nickname = [NSString stringWithUTF8String:(const char *)nickname];
                    NSString *model_smallLogo = [NSString stringWithUTF8String:(const char *)smallLogo];
                    LTAnchorModel *model = [[LTAnchorModel alloc] init];
                    model.uid = uid;
                    model.title = model_title;
                    model.nickname = model_nickname;
                    model.smallLogo = model_smallLogo;
                    
                    [courseArr addObject:model];
                }
                //
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询主播表失败");
            }
            sqlite3_finalize(stmt);
            return courseArr;
            
        }
            break;
        case LTSound:
        {
            NSString *sqlStr = @"select * from sound";
            
            NSMutableArray *courseArr = [NSMutableArray array];
            
            sqlite3_stmt *stmt = nil;
            
            int result = sqlite3_prepare_v2(dbPoint, [sqlStr UTF8String], -1, &stmt, nil);
            
            if (result == SQLITE_OK) {
                NSLog(@"查询所有听单表格成功!");
                //  @"create table if not exists sound (number integer primary key autoincrement,albumId integer, coverMiddle text, nickname text, title text, comments integer, duration integer, playtimes integer, createdAt integer, musicIndex integer)"
                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    NSInteger albumId = sqlite3_column_int64(stmt, 1);
                    const unsigned char *coverMiddle = sqlite3_column_text(stmt, 2);
                    const unsigned char *nickname = sqlite3_column_text(stmt, 3);
                    const unsigned char *title = sqlite3_column_text(stmt, 4);
                    NSInteger comments = sqlite3_column_int64(stmt, 5);
                    NSInteger duration = sqlite3_column_int64(stmt, 6);
                    NSInteger playtimes = sqlite3_column_int64(stmt, 7);
                    NSInteger createdAt = sqlite3_column_int64(stmt, 8);
                    NSInteger musicIndex = sqlite3_column_int64(stmt, 9);
                    NSInteger trackId = sqlite3_column_int64(stmt, 10);
                    NSInteger maxPage = sqlite3_column_int64(stmt, 11);
                    
                    NSString *model_Middle = [NSString stringWithUTF8String:(const char *)coverMiddle];
                    NSString *model_title = [NSString stringWithUTF8String:(const char *)title];
                    NSString *model_nickname = [NSString stringWithUTF8String:(const char *)nickname];
                    LTVoiceModel *model = [[LTVoiceModel alloc] init];
                    model.albumId = albumId;
                    model.coverMiddle = model_Middle;
                    model.nickname = model_nickname;
                    model.title = model_title;
                    model.comments = comments;
                    model.duration = duration;
                    model.playtimes = playtimes;
                    model.createdAt = createdAt;
                    model.musicIndex = musicIndex;
                    model.trackId = trackId;
                    model.maxPage = maxPage;
                    [courseArr addObject:model];
                }
                //
            }else{
                sqlite3_finalize(stmt);
                NSLog(@"查询声音表失败");
            }
            sqlite3_finalize(stmt);
            return courseArr;

        }
            break;
    }
}

- (void)deleteAllCourseWith:(LTDataType)type
{
    switch (type) {
        case LTAlbum:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from album"];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除全部专辑成功!");
            }else{
                NSLog(@"删除全部专辑失败!");
            }
        }
            break;
        case LTVoice:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from voice"];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除全部听单成功!");
            }else{
                NSLog(@"删除全部听单失败!");
            }
        }
            break;
        case LTRadio:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from radio"];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除全部广播成功!");
            }else{
                NSLog(@"删除全部广播失败!");
            }
        }
            break;
        case LTAnchor:
        {
            
        }
            break;
        case LTSound:
        {
            NSString *sqlStr = [NSString stringWithFormat:@"delete from sound"];
            
            int result = sqlite3_exec(dbPoint, [sqlStr UTF8String], nil, nil, nil);
            if (result == SQLITE_OK) {
                NSLog(@"删除全部声音成功!");
            }else{
                NSLog(@"删除全部声音失败!");
            }
        }
            break;
    }
}







@end
